<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <title>发送消息</title>
</head>
<body>
<h2>发送 RabbitMQ 消息</h2>
<input type="text" id="msg" placeholder="请输入消息内容">
<button onclick="sendMessage()">发送</button>
<p id="result"></p>

<script>
    function sendMessage() {
        const msg = document.getElementById('msg').value;
        fetch('/mq/send?msg=' + encodeURIComponent(msg), { method: 'POST' })
            .then(resp => resp.text())
            .then(data => document.getElementById('result').innerText = data)
            .catch(err => document.getElementById('result').innerText = '发送失败: ' + err);
    }
</script>
</body>
</html>
